package slicktemplate;

import java.awt.geom.Point2D;

/**
 * @author Josh
 * This class helps with Maths.
 * Add and methods that you think you will be doing frequently.
 */
public class MathHelper {

    public static float point_direction(float x1, float y1, float x2, float y2) {
        return (float) Math.atan2(y2 - y1, x2 - x1);
    }

    public static Point2D.Float align_to_grid(float x, float y) {
        return new Point2D.Float((Math.round(x / 32) * 32), (Math.round(y / 32) * 32));
    }
    public static float align_to_grid_point(float x){
        return Math.round((int)x/32)*32;
    }

    public static Point2D.Float check_align_to_grid(float x, float y) {
        float offx = (Math.round(x/32)*32) - x;
        float offy = (Math.round(y/32)*32) - y;
        return new Point2D.Float(offx, offy);
    }
    public static float point_distance(float x1, float y1, float x2, float y2){
        return (float) Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2 - y1 , 2));
    }
}
